﻿namespace Morus
{
    using System;
    using System.Diagnostics;

    public static partial class ObjectExtension
    {
        [DebuggerStepThrough]
        public static T NullSafe<T>(this T target, Func<T> defaultValue)
            where T : class
        {
            if (target == null || target is DBNull)
                return defaultValue();
            else
                return target;
        }
    }
}
